package com.atguigu.edupublisher.mapper;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

@Mapper
public interface SugarMapper {

    /**
     *  各省份当天的订单总额
     * @param date
     * @return
     */
    @Select("select province_id,province_name,order_amount from dws_trade_province_order_window where toYYYYMMDD(stt)=&{date}")
    BigDecimal  getProvinceOrderAmount(int date);

    @Select("select sum(order_amount) order_amount from dws_trade_order_window where toYYYYMMDD(stt)=${date}")
    BigDecimal selectGmv(int date);

    @Select("select sum(order_count) order_count,sum(order_user_count) order_user_count from dws_trade_order_window where toYYYYMMDD(stt)=&{date}")
    BigDecimal selectCount(int date);

    @Select("select course_name,sum(course_order_amount) order_amount from dws_course_order_window where toYYYYMMDD(stt)=${date} group by course_name order by order_amount desc limit ${limit}")
    List<Map<String, Object>> selectGmvByCourse(@Param("date") int date, @Param("limit") int limit);
}
